package com.project.demo.config;

import com.project.demo.interceptor.LoginInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

/**
 */
@Configuration//标明配置类
@EnableOpenApi//开启swagger功能
@Slf4j
public class WebAppConfig implements WebMvcConfigurer {

//    @Override
//    public void addInterceptors(InterceptorRegistry registry) {
//        //登录拦截的管理器
//        InterceptorRegistration registration = registry.addInterceptor(loginInterceptor());
//        //拦截的地址
//        registration.addPathPatterns("/**");
//        //方行的地址
////        registration.excludePathPatterns("/**");
//        //根据需要拦截，一般设置所有地址拦截，放行公共连接
//    }
//
//    @Bean
//    public LoginInterceptor loginInterceptor(){
//        return new LoginInterceptor();
//    }

//    @Bean
//    public Docket createRestApi(){
//        return new Docket(DocumentationType.OAS_30)
//                .apiInfo(apiInfo())
//                .select()
//                .apis(RequestHandlerSelectors.basePackage("com.project.dome.controller"))
//                .paths(PathSelectors.any())
//                .build();
//    }
//    private ApiInfo apiInfo(){
//        return new ApiInfoBuilder()
//                .title("电影购票系统")
//                .description("进行基础购票功能")
//                .termsOfServiceUrl("")
//                .version("1.0")
//                .build();
//    }

}
